//
//  PicSelCell.swift
//  SinaWeiBo
//
//  Created by ZKJ on 2017/9/21.
//  Copyright © 2017年 ZKJ. All rights reserved.
//

import UIKit

class PicSelCell: UICollectionViewCell {
    
    // MARK:- 控件
    @IBOutlet weak var addButton: UIButton!
    @IBOutlet weak var picImgView: UIImageView!
    @IBOutlet weak var delButton: UIButton!
    
    // MARK:- 属性
    var image : UIImage? {
        didSet {
            if image != nil {
                picImgView.image = image
                addButton.isUserInteractionEnabled = false
                delButton.isHidden = false
            } else {
                picImgView.image = nil
                addButton.isUserInteractionEnabled = true
                delButton.isHidden = true
            }
        }
    }
    
    @IBAction func addPhotoClick() {
        NotificationCenter.default.post(name: NSNotification.Name(PicPickerAddPhotoNote), object: nil)
    }
    
    @IBAction func deleteClick() {
        NotificationCenter.default.post(name: Notification.Name(PicPickerDeletePhotoNote), object: picImgView.image)
    }
}
